from sklearn.metrics import mean_squared_error
from 线性回归模型的类封装 import LinearRegression
from sklearn.model_selection import train_test_split
import pandas as pd

data = pd.read_csv('california_housing_s.csv')
print(data)

X = data['median_house_value']
y = data.drop('median_house_value', axis = 1)

lr = LinearRegression()
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.15)
# print(X_train.shape, y_train.shape)  
# print(X_test.shape, y_test.shape)

lr.fit(X_train, y_train)

s = mean_squared_error(X_test, lr.predict(y_test))
print(s)

# 5.预测模型

# X_new = data['median_house_value']
# s = lr.predict[X_new]
# print(s)